package com.dhj.lambdaTest;

import java.util.function.IntBinaryOperator;

public class Demo2 {


    public static void main(String[] args) {
        int num = calculateNum(new IntBinaryOperator() {
            @Override
            public int applyAsInt(int left, int right) {
                return left + right;
            }
        });
        System.out.println(num);

        // Lambda表达式写法
        int num2 = calculateNum((left, right) -> {
            return left + right;
        });
        System.out.println(num2);
    }


    public static int calculateNum(IntBinaryOperator operator) {
        int a = 10;
        int b = 20;
        return operator.applyAsInt(a, b);
    }

}
